-
Notifications
You must be signed in to change notification settings - Fork 2.3k
fix(mesonlsp): improved root detection #3775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
1febf14
to
afbd86a
Compare
1a3a3f7
to
c9000bb
Compare
This commit enhances root directory detection of mesonlsp language server. Current behavior: root is set on first meson file user is opened New behavior: root is set to parent of meson.build with project function call
c9000bb
to
c4aaf0c
Compare
for line in io.lines(f) do | ||
-- skip meson comments | ||
if not line:match '^%s*#.*' then | ||
local str = line:gsub('%s+', '') | ||
if str ~= '' then | ||
if str:match '^project%(' then | ||
return true | ||
else | ||
break |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vim.filetype.match()
exists for this purpose. However,
vim.filetype.match({ filename = f, contents = 'project' })
seems to return "meson" even if the file doesn't contain "project", which isn't what you want here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For mesonlsp root_dir is required to be at folder with 'project' file. If root will be in different place all file will be underlined with red. I just take code from vala_ls which finds project root perfectly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just take code from vala_ls which finds project root perfectly.
Yeah, I'm trying to find more concise patterns so that we don't have to maintain 10x as much code in all of these configs.
This commit enhances root directory detection of mesonlsp language server.
Current behavior:
root
is set on first meson file user is openedNew behavior:
root
is set to parent ofmeson.build
withproject
function call